/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.cr.cR.Array;
import org.xtext.example.cr.cR.ArrayDec;
import org.xtext.example.cr.cR.CRPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Array Dec</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArrayDecImpl#getArray <em>Array</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArrayDecImpl#getColums <em>Colums</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArrayDecImpl#getRows <em>Rows</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArrayDecImpl#getType <em>Type</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.ArrayDecImpl#getArrayVars <em>Array Vars</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArrayDecImpl extends MinimalEObjectImpl.Container implements ArrayDec
{
  /**
   * The default value of the '{@link #getArray() <em>Array</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArray()
   * @generated
   * @ordered
   */
  protected static final String ARRAY_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getArray() <em>Array</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArray()
   * @generated
   * @ordered
   */
  protected String array = ARRAY_EDEFAULT;

  /**
   * The default value of the '{@link #getColums() <em>Colums</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getColums()
   * @generated
   * @ordered
   */
  protected static final int COLUMS_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getColums() <em>Colums</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getColums()
   * @generated
   * @ordered
   */
  protected int colums = COLUMS_EDEFAULT;

  /**
   * The default value of the '{@link #getRows() <em>Rows</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRows()
   * @generated
   * @ordered
   */
  protected static final int ROWS_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getRows() <em>Rows</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRows()
   * @generated
   * @ordered
   */
  protected int rows = ROWS_EDEFAULT;

  /**
   * The default value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected static final String TYPE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected String type = TYPE_EDEFAULT;

  /**
   * The cached value of the '{@link #getArrayVars() <em>Array Vars</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArrayVars()
   * @generated
   * @ordered
   */
  protected EList<Array> arrayVars;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ArrayDecImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.ARRAY_DEC;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getArray()
  {
    return array;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArray(String newArray)
  {
    String oldArray = array;
    array = newArray;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ARRAY_DEC__ARRAY, oldArray, array));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getColums()
  {
    return colums;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setColums(int newColums)
  {
    int oldColums = colums;
    colums = newColums;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ARRAY_DEC__COLUMS, oldColums, colums));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getRows()
  {
    return rows;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRows(int newRows)
  {
    int oldRows = rows;
    rows = newRows;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ARRAY_DEC__ROWS, oldRows, rows));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(String newType)
  {
    String oldType = type;
    type = newType;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.ARRAY_DEC__TYPE, oldType, type));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Array> getArrayVars()
  {
    if (arrayVars == null)
    {
      arrayVars = new EObjectContainmentEList<Array>(Array.class, this, CRPackage.ARRAY_DEC__ARRAY_VARS);
    }
    return arrayVars;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.ARRAY_DEC__ARRAY_VARS:
        return ((InternalEList<?>)getArrayVars()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.ARRAY_DEC__ARRAY:
        return getArray();
      case CRPackage.ARRAY_DEC__COLUMS:
        return getColums();
      case CRPackage.ARRAY_DEC__ROWS:
        return getRows();
      case CRPackage.ARRAY_DEC__TYPE:
        return getType();
      case CRPackage.ARRAY_DEC__ARRAY_VARS:
        return getArrayVars();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.ARRAY_DEC__ARRAY:
        setArray((String)newValue);
        return;
      case CRPackage.ARRAY_DEC__COLUMS:
        setColums((Integer)newValue);
        return;
      case CRPackage.ARRAY_DEC__ROWS:
        setRows((Integer)newValue);
        return;
      case CRPackage.ARRAY_DEC__TYPE:
        setType((String)newValue);
        return;
      case CRPackage.ARRAY_DEC__ARRAY_VARS:
        getArrayVars().clear();
        getArrayVars().addAll((Collection<? extends Array>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ARRAY_DEC__ARRAY:
        setArray(ARRAY_EDEFAULT);
        return;
      case CRPackage.ARRAY_DEC__COLUMS:
        setColums(COLUMS_EDEFAULT);
        return;
      case CRPackage.ARRAY_DEC__ROWS:
        setRows(ROWS_EDEFAULT);
        return;
      case CRPackage.ARRAY_DEC__TYPE:
        setType(TYPE_EDEFAULT);
        return;
      case CRPackage.ARRAY_DEC__ARRAY_VARS:
        getArrayVars().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.ARRAY_DEC__ARRAY:
        return ARRAY_EDEFAULT == null ? array != null : !ARRAY_EDEFAULT.equals(array);
      case CRPackage.ARRAY_DEC__COLUMS:
        return colums != COLUMS_EDEFAULT;
      case CRPackage.ARRAY_DEC__ROWS:
        return rows != ROWS_EDEFAULT;
      case CRPackage.ARRAY_DEC__TYPE:
        return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
      case CRPackage.ARRAY_DEC__ARRAY_VARS:
        return arrayVars != null && !arrayVars.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (array: ");
    result.append(array);
    result.append(", colums: ");
    result.append(colums);
    result.append(", rows: ");
    result.append(rows);
    result.append(", type: ");
    result.append(type);
    result.append(')');
    return result.toString();
  }

} //ArrayDecImpl
